<template>


  <el-dialog
      v-model="props.InsertUserSystem.dialogVisible"
      title="绑定"
      width="30%"
      :before-close="handleClose"
  >
    <div>账号: ：<el-input style="width: 300px" v-model="props.InsertUserSystem.data.userName"/></div>
   <div> 密码: ：<el-input style="width: 300px" v-model="props.InsertUserSystem.data.password"/></div>
    <template #footer>
      <span class="dialog-footer">
        <el-button @click="insertUserMethod">确认</el-button>
        <el-button type="primary" @click="props.InsertUserSystem.dialogVisible = false">
          取消
        </el-button>
      </span>
    </template>
  </el-dialog>
</template>

<script lang="ts" setup>
import {reactive, ref} from 'vue'
import { ElMessageBox } from 'element-plus'
import axios from "axios";
const props =defineProps({
  InsertUserSystem:{
    type:Object
  }
})
const dialogVisible = ref(false)

const insertUserMethod =()=>{
  props.InsertUserSystem.dialogVisible = false
  const url = "http://localhost:1688/login/insertUser"
  axios.post(url,props.InsertUserSystem.data).then(data=>{
    const sysUserId= data.data.data.id;
    const recordId =props.InsertUserSystem.data.userPosition;
    axios.get(`http://localhost:1688/record/selectSatff/${recordId}`).then(data=>{
      const departmentId= data.data.data.departmentId
      const positionId = data.data.data.positionId
      axios.get(`http://localhost:1688/login/bindang/${sysUserId}/${departmentId}/${positionId}`).then(data=>{
      })
    })
  })
}
const handleClose = (done: () => void) => {
  ElMessageBox.confirm('你确定能关闭？')
      .then(() => {
        done()
      })
      .catch(() => {
        // catch error
      })
}
</script>
<style scoped>
.dialog-footer button:first-child {
  margin-right: 10px;
}
</style>
